Add xmalloc_bytes() to the allocator API.
Signed-off-by: keir.fraser@cl.cam.ac.uk
#define DECLARE_MUTEX(_m) spinlock_t _m = SPIN_LOCK_UNLOCKED
#define down(_m) spin_lock(_m)
#define up(_m) spin_unlock(_m)
-#define vmalloc(_s) ((void *)xmalloc(u8[_s]))
+#define vmalloc(_s) xmalloc_bytes(_s)
#define vfree(_p) xfree(_p)
#define num_online_cpus() smp_num_cpus
static inline int on_each_cpu(
if (ret & 0xff00)
printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", (ret >> 8) & 0xff);
else if (opt.size) {
- rt = (struct irq_routing_table *)xmalloc(u8[sizeof(struct irq_routing_table) + opt.size]);
+ rt = xmalloc_bytes(sizeof(struct irq_routing_table) + opt.size);
if (rt) {
memset(rt, 0, sizeof(struct irq_routing_table));
rt->size = opt.size + sizeof(struct irq_routing_table);
{
SH_LOG("Allocate more shadow hashtable blocks.");
- extra = (struct shadow_status *)xmalloc(
- u8[sizeof(void *) + (shadow_ht_extra_size * sizeof(*x))]);
+ extra = xmalloc_bytes(
+ sizeof(void *) + (shadow_ht_extra_size * sizeof(*x)));
/* XXX Should be more graceful here. */
if ( extra == NULL )
extern void dump_slabinfo();
-/* Nicely typesafe for you. */
-#define xmalloc(_type) ((typeof(_type) *)_xmalloc(sizeof(_type)))
+/* Allocate space for typed object. */
+#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type)))
+
+/* Allocate space for array of typed objects. */
#define xmalloc_array(_type, _num) \
((_type *)(((_num) > (UINT_MAX / sizeof(_type))) ? \
NULL : _xmalloc((_num) * sizeof(_type))))
+
+/* Allocate untyped storage. */
+#define xmalloc_bytes(_bytes) (_xmalloc(_bytes))
+
#endif /* __ARCH_HAS_SLAB_ALLOCATOR */
#endif /* __SLAB_H__ */